package com.git_taoxina.homework.test3;

public class Test {
    public static void main(String[] args) {
//        定义实体类对象
        Threads thr = new Threads(100);
//        创建一个SaleTickets对象并将实体对象作为参数进行传递
        SaleTickets saleTickets = new SaleTickets(thr);
//        开启线程
        new Thread(saleTickets,"1号:").start();
        new Thread(saleTickets,"2号:").start();
        new Thread(saleTickets,"3号:").start();
    }
}
//买票类
class SaleTickets implements Runnable{
    private Threads threads;

    public SaleTickets() {
    }
    public SaleTickets(Threads threads) {
        this.threads = threads;
    }

    @Override
    public void run() {
        while (threads.getTickets() > 0) {
            threads.getTicket(100);
        }
    }
}
